<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [10, 200, 33, 24, 0, 15, 0, 66, 17, 98]
        //  1. 将数组中的0项去掉，将不为0的值存入一个新的数组，生成新的数组
        let newArr = []
        for (let i of arr.keys()) {
            if (arr[i] !== 0) {
                newArr.push(arr[i])
            }
        }
        // 去0新数组
        console.log(newArr, '去0新数组')


        let sum = 0
        let eveSum = 0
        let oddSum = 0
        let max = 0
        let min = 0
        for (let i of newArr.keys()) {
            sum += arr[i]
            newArr[i] % 2 == 0 ? eveSum += newArr[i] : oddSum += newArr[i]
            if (newArr[i] > max) {
                max = newArr[i]
            }
            if (newArr[i] < min) {
                min = newArr[i]
            }
        }
        console.log(eveSum, '偶数和')
        //  3. 求新数组中的奇数的和
        console.log(oddSum, '奇数和')
        // 最大值。最小值
        console.log(max, '最大值')
        console.log(min, '最小值')

        //  4. 求新数组中的最大值 及最大值对应的下标
        for (let i of newArr.keys()) {
            if (newArr[i] == max) {
                console.log(`新数组中的最大值 及最小值对应的下标${i}`)
            }
        }

        // //  5. 求新数组中的最小值 及最小值对应的下标
        for (let i of newArr.keys()) {
            if (newArr[i] == min) {
                console.log(`新数组中的最大值 及最小值对应的下标${i}`)
            }
        }

        // 求每一项和
        console.log(sum, '数组的和')



        //  6. 将新数组进行倒序遍历（从最后一项开始输出）
        let temp
        for (let i = 0; i < newArr.length / 2; i++) {

            temp = newArr[i]
            newArr[i] = newArr[newArr.length - 1 - i]
            newArr[newArr.length - 1 - i] = temp
        }
        console.log(newArr)



    </script>

</body>

</html>